Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lines-and-columns

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lines-and-columns

Maps lines and columns to character offsets and back.

  • 1.2.4
  • v12x
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is lines-and-columns?

The lines-and-columns npm package is used to map between lines and columns to character offsets within a string, which is particularly useful when dealing with source code or any structured text format where line and column positions are commonly used.

What are lines-and-columns's main functionalities?

Index to Position

This feature allows you to convert a line and column position into a character offset index. It is useful when you have a line and column number and you want to find the corresponding position in a flat string.

{"const LinesAndColumns = require('lines-and-columns');\nconst lines = new LinesAndColumns('Hello\nWorld');\nconst location = lines.indexForLocation({ line: 1, column: 2 }); // returns 9"}

Position to Index

This feature allows you to convert a character offset index back into a line and column position. It is useful when you have an index in a string and you need to find out which line and column it corresponds to.

{"const LinesAndColumns = require('lines-and-columns');\nconst lines = new LinesAndColumns('Hello\nWorld');\nconst position = lines.locationForIndex(7); // returns { line: 1, column: 0 }"}

Other packages similar to lines-and-columns

Keywords

FAQs

Package last updated on 21 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc